<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script>
    // aabccd，去掉重复的字符，使结果显示 abcd

    var str = "aabccd";
    var arr = str.split("")
    // console.log(arr);
    let res = arr.reduce(function (pre, cur) {
      return (pre.indexOf(cur) === -1) ? pre.concat(cur) : pre
    }, [])
    // console.log(res);
    let str2 = res.join("")
    console.log(str2);
  </script>
</body>

</html>